package com.xialuo.study.std;

import org.bsc.langgraph4j.serializer.Serializer;
import org.springframework.ai.chat.messages.SystemMessage;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

public class SystemMessageSerializer implements Serializer<SystemMessage> {


    @Override
    public void write(SystemMessage object, ObjectOutput out) throws IOException {
        out.writeUTF(object.getText());
    }

    @Override
    public SystemMessage read(ObjectInput in) throws IOException, ClassNotFoundException {
        String text = in.readUTF();
        return new SystemMessage(text);
    }
}
